﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DALScolarite 
{
    public partial class scolarite_groupeclass
    {
        uvtmoyEntities ent;
        public List<scolarite_groupeclass> groupeclasse(string idclass)
        {
            ent = new uvtmoyEntities();
            var query = from e in ent.scolarite_groupeclass 
                        where e.idClasse==idclass
                            select e;
            return query.ToList();
        }

        public List<scolarite_groupeclass> groupeclassediplome(string iddiplome, string idclass)
        {
            ent = new uvtmoyEntities();
            var query = from e in ent.scolarite_groupeclass
                        where e.idClasse == idclass 
                        select e;
            return query.ToList();
        }

        public List<EtudiantsInscript> EtudiantParGroupe(string iddiplome, string idclasse, string idanneeuniv)
        {
            ent = new uvtmoyEntities();
            var query = from s in ent.scolarite_inscription
                        join e in ent.scolarite_etudiants on s.idetudiants equals e.idetudiants
                        join gri in ent.scolarite_inscriptgroupeclass on s.idInscription equals gri.idInscription
                        join gr in ent.scolarite_groupeclass on gri.idGroupeClass equals gr.idGroupeClass
                        join cls in ent.scolarite_classes on gr.idClasse equals cls.idClasse
                        where s.idEltDiplome == iddiplome && s.idClasse == idclasse && s.idAnneeUniv == idanneeuniv  
                        orderby e.NomFR, e.PrenomFR,cls.idClasse, gr.idGroupeClass
                        select new EtudiantsInscript()
                        {
                            idetudiants = e.idetudiants,
                            idInscription = s.idInscription,
                            NomFR = e.NomFR,
                            PrenomFR = e.PrenomFR,
                            email = e.email,
                            sex = e.sex,
                            cin = e.cin,
                            idGroupeClass = gr.idGroupeClass,
                            label = cls.label,
                            NomDeGroupe = gr.NomDeGroupe,
                            idClasse = cls.idClasse
                        }
                          ;


            return query.ToList();
        
        
        }

    }
}
